﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <script type="text/javascript" src="../../Content/highlighter/scripts/shCore.js"></script>
    <script type="text/javascript" src="../../Content/highlighter/scripts/shBrushJScript.js"></script>
    <script type="text/javascript" src="../../Content/highlighter/scripts/shBrushCSharp.js"></script>
    <script type="text/javascript" src="../../Content/highlighter/scripts/shBrushXml.js"></script>
    <link type="text/css" rel="stylesheet" href="../../Content/highlighter/styles/shCore.css" />
    <link type="text/css" rel="stylesheet" href="../../Content/highlighter/styles/shCoreEclipse.css" />
    <script type="text/javascript">SyntaxHighlighter.all();</script>
</head>
<body>
    <h3>授权过滤器</h3>
    <b>下接是授权过滤器接口：</b>
    <p>
        该过滤器主要用于权限验证
    </p>
    <pre class="brush:csharp;">
        namespace NFinal.Filter
        {
            public interface IAuthorizationFilter
            {
                bool AuthorizationFilter&lt;TContext, TRequest>(NFinal.Action.AbstractAction&lt;TContext, TRequest> action);
            }
        }
    </pre>
    <b>1.实现授权过滤器</b>
    <pre class="brush:csharp;">
        [AttributeUsage(AttributeTargets.Method)]
        public class UserCheckAttribute : NFinal.Filter.IAuthorizationFilter
        {
            public bool AuthorizationFilter&lt;TContext, TRequest>(NFinal.Action.AbstractAction&lt;TContext, TRequest> action)
            {
                if(this.parameters["account"]=="Lucas"
                    && this.parameters["password"]="123456"
                )
                {
                    return true;
                }
                return false;
            }
        }
    </pre>
    <b>2.如何使用</b>
    <p>如果验证通不过，则页面会返回空。</p>
    <pre class="brush:csharp;">
        public class IndexController : BaseController
        {
            [UserCheck]
            public void Index()
            {
                this.Write("Hello World!");
            }
        }
    </pre>
</body>
</html>